<?php

function setFlash($message, $flashClass = "error") {
  $_SESSION['_flash'] = $message;
  $_SESSION['_flashClass'] = $flashClass;
}

function getFlash($discard = false) {
  $what_to_retun = null;
  
  if ( array_key_exists('_flash', $_SESSION) ) {
    $what_to_retun = $_SESSION['_flash'];
  } else {
    $what_to_retun = false;
  }
  
  if ($discard == true) discardFlash();
  
  return $what_to_retun;
}

function getFlashClass() {
  if ( array_key_exists('_flashClass', $_SESSION) ) {
    return $_SESSION['_flashClass'];
  } else {
    return "";
  }
}

function discardFlash() {
  unset( $_SESSION['_flash'] );
}

?>
